package 尚硅谷juc大厂.test9;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;
import java.util.concurrent.locks.ReentrantLock;

public class Test9 {


    public static void main(String[] args) throws InterruptedException {
        Thread a = new Thread(() -> {
            System.out.println(Thread.currentThread().getName()+"\t"+"开始执行");
            /**
             * 两个park()
             */
            LockSupport.park();
            LockSupport.park();
            System.out.println(Thread.currentThread().getName()+"\t"+"被唤醒");
        },"a");
        a.start();

        TimeUnit.SECONDS.sleep(3);

        Thread b = new Thread(() -> {
            /**
             * 2次唤醒
             */
            LockSupport.unpark(a);
            LockSupport.unpark(a);
            System.out.println(Thread.currentThread().getName()+"\t"+"发出通知");
        },"b");
        b.start();
    }
}
